
#pragma once
namespace micro{



namespace app
{

class QRegistry
{
public:
	QRegistry();
	~QRegistry();

int m_nLastError;

// QRegistry properties	
protected:
	HKEY m_hRootKey;
	bool m_bLazyWrite;
	QString m_strCurrentPath;

public:
	inline bool PathIsValid() {	return (m_strCurrentPath.GetLength() > 0); }
	inline QString GetCurrentPath() {return m_strCurrentPath; }
	inline HKEY GetRootKey() { return m_hRootKey; }


//QRegistry	methods
public:
	bool ClearKey();
	bool SetRootKey(HKEY hRootKey);
	bool CreateKey(QString strKey);
	bool DeleteKey(QString strKey);
	bool DeleteValue(QString strName);
	int GetDataSize(QString strValueName);
	DWORD GetDataType(QString strValueName);
	int GetSubKeyCount();
	int GetValueCount();
	bool KeyExists(QString strKey, HKEY hRootKey = nullptr);
	bool SetKey(QString strKey, bool bCanCreate);
	bool ValueExists(QString strName);
	void RenameValue(QString strOldName, QString strNewName);

	// data reading functions
	//COleDateTime ReadDateTime(QString strName, COleDateTime dtDefault);
	
	
	double ReadFloat(QString strName, double fDefault);
	QString ReadString(QString strName, QString strDefault);
	int ReadInt(QString strName, int nDefault);
	bool ReadBool(QString strName, bool bDefault);
	COLORREF ReadColor(QString strName, COLORREF rgbDefault);
	bool ReadFont(QString strName, QFont* pFont);
	bool ReadPoint(QString strName, QPoint* pPoint);
	bool ReadSize(QString strName, QSize* pSize);
	bool ReadRect(QString strName, QRect* pRect);
	DWORD ReadDword(QString strName, DWORD dwDefault);

	// data writing functions
	bool WriteBool(QString strName, bool bValue);

	//bool WriteDateTime(QString strName, COleDateTime dtValue);
	
	bool WriteString(QString strName, QString strValue);
	bool WriteFloat(QString strName, double fValue);
	bool WriteInt(QString strName, int nValue);
	bool WriteColor(QString strName, COLORREF rgbValue);
	bool WriteFont(QString strName, QFont* pFont);
	bool WritePoint(QString strName, QPoint* pPoint);
	bool WriteSize(QString strName, QSize* pSize);
	bool WriteRect(QString strName, QRect* pRect);
	bool WriteDword(QString strName, DWORD dwValue);

};// end of QRegistry class definition


 

}

}//micro